home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene 96
/
Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso
/
misc
/
coding
/
cp2dekit
/
samples
/
inppplay.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-29
|
6KB
|
260 lines
//***************************************************************************
//
// this file is (c) '94-'96 Niklas Beisert
//
// this file is part of the cubic player development kit.
// you may only use/modify/spread this file under the terms stated
// in the cubic player development kit accompanying documentation.
//
//***************************************************************************
//[defaultconfig] ;// default configuration
// link=playinp
//[fileselector] ;// default fileselector section
// readdirs=_inpReadDirReg
//[filetype 23]
// color=2
// name=INP
// interface=_plCubicPlayer
// player=_inpPlayer
// player example
// sampling example
// additional readdir example
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include "pfilesel.h"
#include "poutput.h"
#include "sampler.h"
#include "psetting.h"
#include "ss.h"
#include "devigen.h"
#include "devisamp.h"
#include "cpiface.h"
static char cdpMode;
static void cdaDrawGStrings(short (*buf)[132])
{
if (plScrWidth==80)
{
writestring(buf[0], 0, 0x09, " mode: .......... ", 80);
writestring(buf[0], 8, 0x0F, cdpMode?"microphone":"line-in", 10);
writestring(buf[1], 0, 0, "", 80);
writestring(buf[2], 0, 0, "", 80);
}
else
{
writestring(buf[0], 0, 0x09, " mode: .......... ", 132);
writestring(buf[0], 10, 0x0F, cdpMode?"microphone":"line-in", 10);
writestring(buf[1], 0, 0, "", 132);
writestring(buf[2], 0, 0, "", 132);
}
}
static void cdaCloseFile()
{
smpCloseSampler();
}
static int inpProcessKey(unsigned short key)
{
if (smpProcessKey)
{
int ret=smpProcessKey(key);
if (ret==2)
cpiResetScreen();
if (ret)
return 1;
}
return 0;
}
static int inpOpenFile(const char *path, moduleinfostruct &info, binfile *)
{
char name[_MAX_FNAME];
char ext[_MAX_FNAME];
_splitpath(path, 0, 0, name, ext);
if (stricmp(name, "DEFAULT"))
smpSetDevice(name, 0);
if (!smpSample)
return -1;
cdpMode=strcmp(ext, ".MIC")?1:0;
smpSetSource(cdpMode?SMP_LINEIN:SMP_MIC);
plDrawGStrings=cdaDrawGStrings;
plGetMasterSample=smpGetMasterSample;
plGetRealMasterVolume=smpGetRealMasterVolume;
plProcessKey=inpProcessKey;
smpSetOptions(plsmpRate, plsmpOpt);
void *buf;
int len;
if (!smpOpenSampler(buf, len))
return -1;
return 0;
}
static int inpReadDir(modlist &ml, unsigned short dirref, const char *mask, unsigned long opt)
{
if (!plSamplerDevices)
return 1;
char path[_MAX_PATH];
modlistentry m;
if (opt&RD_PUTDSUBS)
{
fsConvFileName12(m.name, "@:", "");
m.fileref=0xFFFF;
m.dirref=dmGetDriveDir(0);
if (!mdbAppendNew(ml, m))
return 0;
}
if (opt&RD_PUTSUBS)
{
dmGetPath(path, dirref);
if (!strcmp(path, "@:\\"))
{
fsConvFileName12(m.name, "INPUTS", "");
dmGetPath(path, dirref);
strcat(path, "INPUTS");
m.dirref=dmGetPathReference(path);
if (m.dirref==0xFFFF)
return 0;
m.fileref=0xFFFE;
if (!mdbAppend(ml, m))
return 0;
}
}
dmGetPath(path, dirref);
if (!strcmp(path, "@:\\INPUTS\\"))
{
devinfonode *dev;
for (dev=plSamplerDevices; dev; dev=dev->next)
{
char hnd[9];
strcpy(hnd, dev->handle);
strupr(hnd);
fsConvFileName12(m.name, hnd, ".LIN");
if (fsMatchFileName12(m.name, mask))
{
m.dirref=dirref;
m.fileref=mdbGetModuleReference(m.name, dev->ihandle);
if (m.fileref==0xFFFF)
return 0;
if (mdbGetModuleType(m.fileref)!=mtINP)
{
moduleinfostruct mi;
mdbGetModuleInfo(mi, m.fileref);
mi.flags1|=MDB_VIRTUAL;
mi.channels=2;
strcpy(mi.modname, dev->dev.dev->name);
mi.modtype=mtINP;
mdbWriteModuleInfo(m.fileref, mi);
}
if (!mdbAppend(ml, m))
return 0;
}
strcpy(hnd, dev->handle);
strupr(hnd);
fsConvFileName12(m.name, hnd, ".MIC");
if (fsMatchFileName12(m.name, mask))
{
m.dirref=dirref;
m.fileref=mdbGetModuleReference(m.name, dev->ihandle);
if (m.fileref==0xFFFF)
return 0;
if (mdbGetModuleType(m.fileref)!=mtINP)
{
moduleinfostruct mi;
mdbGetModuleInfo(mi, m.fileref);
mi.flags1|=MDB_VIRTUAL;
mi.channels=1;
strcpy(mi.modname, dev->dev.dev->name);
mi.modtype=mtINP;
mdbWriteModuleInfo(m.fileref, mi);
}
if (!mdbAppend(ml, m))
return 0;
}
}
fsConvFileName12(m.name, "DEFAULT", ".LIN");
if (fsMatchFileName12(m.name, mask))
{
m.dirref=dirref;
m.fileref=mdbGetModuleReference(m.name, 0);
if (m.fileref==0xFFFF)
return 0;
if (mdbGetModuleType(m.fileref)!=mtINP)
{
moduleinfostruct mi;
mdbGetModuleInfo(mi, m.fileref);
mi.flags1|=MDB_VIRTUAL;
mi.channels=2;
strcpy(mi.modname, "Default Line-In");
mi.modtype=mtINP;
mdbWriteModuleInfo(m.fileref, mi);
}
if (!mdbAppend(ml, m))
return 0;
}
fsConvFileName12(m.name, "DEFAULT", ".MIC");
if (fsMatchFileName12(m.name, mask))
{
m.dirref=dirref;
m.fileref=mdbGetModuleReference(m.name, 0);
if (m.fileref==0xFFFF)
return 0;
if (mdbGetModuleType(m.fileref)!=mtINP)
{
moduleinfostruct mi;
mdbGetModuleInfo(mi, m.fileref);
mi.flags1|=MDB_VIRTUAL;
mi.channels=1;
strcpy(mi.modname, "Default Microphone");
mi.modtype=mtINP;
mdbWriteModuleInfo(m.fileref, mi);
}
if (!mdbAppend(ml, m))
return 0;
}
}
return 1;
}
extern "C"
{
mdbreaddirregstruct inpReadDirReg = {inpReadDir};
cpifaceplayerstruct inpPlayer = {inpOpenFile, cdaCloseFile};
};